import Koa from 'koa'
import { koaBody } from 'koa-body'
import cors from 'koa-cors'

export default (options = {}) => {
  const { router, port } = {
    port: 1200,
    ...options,
  }

  const app = new Koa()

  app.use(cors())
  app.use(koaBody())

  if (router) router(app)

  app.listen(port)

  console.log(`http://127.0.0.1:${port}`)

  return app
}
